<template> <!--    这是一个模块主页模板-函数需要重新定义赋值 -->
  <el-card shadow="hover">
    <!--    查询条件部分-->
    <el-divider content-position="left"><span style="font-weight: bolder;font-size: 18px">查询条件</span></el-divider>
    <div>
      <el-form ref="showForm" label-position="right" label-width="100px">

        <el-row :gutter="24">
          <el-col :span="9">
            <el-form-item label="员工信息：">
              <el-input v-model="queryParma.ygxx" clearable size="small" placeholder="请输入查询的员工用户名&年龄&备注信息等" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="员工类型：">
              <el-select
                v-model="queryParma.yglxbh"
                style="position: relative;left: 5px"
                filterable
                default-first-option
                placeholder="请选择员工类型"
              >
                <el-option
                  key="0"
                  label=""
                  value=""
                />
                <el-option
                  v-for="item in empTypeList"
                  :key="item.employTypeCode"
                  :label="item.employTypeName"
                  :value="item.employTypeCode"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="7" align="right">
            <el-button type="primary" :loading="searchloding" @click="getEmpInfoListPageHandle">查询</el-button>
            <el-button @click="resetForm">重置</el-button>
            <a style="font-size:14px; margin-left: 10px" @click="toggleSearchStatus = !toggleSearchStatus">
              <template v-if="!toggleSearchStatus">
                展开
                <i class="el-icon-arrow-down" />
              </template>
              <template v-else>
                收起
                <i class="el-icon-arrow-up" />
              </template>
            </a>
          </el-col>
        </el-row>
        <template v-if="toggleSearchStatus">
          <el-row :gutter="24">
            <el-col :span="6">
              <el-form-item label="请假类型：">
                <el-select
                  v-model="queryParma.qjlxbh"
                  style="position: relative;left: 5px"
                  filterable
                  default-first-option
                  placeholder="请选择请假类型"
                >
                  <el-option
                    key="0"
                    label=""
                    value=""
                  />
                  <el-option
                    v-for="item in dictArray.qjlxDictList"
                    :key="item.code"
                    :label="item.value"
                    :value="item.code"
                  />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="部门信息：">
                <el-select
                  v-model="queryParma.bmxxbh"
                  style="position: relative;left: 5px"
                  filterable
                  default-first-option
                  placeholder="请选择部门信息"
                >
                  <el-option
                    key="0"
                    label=""
                    value=""
                  />
                  <el-option
                    v-for="item in depInfoList"
                    :key="item.depCode"
                    :label="item.depName"
                    :value="item.depCode"
                  />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="是否出勤：">
                <el-select
                  v-model="queryParma.sfcq"
                  style="position: relative;left: 5px"
                  filterable
                  default-first-option
                  placeholder="请选择是否出勤"
                >
                  <el-option
                    key="0"
                    label=""
                    value=""
                  />
                  <el-option
                    key="1"
                    label="是"
                    value="1"
                  />
                  <el-option
                    key="2"
                    label="否"
                    value="0"
                  />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="是否请假：">
                <el-select
                  v-model="queryParma.sfqj"
                  style="position: relative;left: 5px"
                  filterable
                  default-first-option
                  placeholder="请选择是否请假"
                >
                  <el-option
                    key="0"
                    label=""
                    value=""
                  />
                  <el-option
                    key="1"
                    label="是"
                    value="11"
                  />
                  <el-option
                    key="2"
                    label="否"
                    value="0"
                  />
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="24">
            <el-col :span="6">
              <el-form-item label="员工状态：">
                <el-select
                  v-model="queryParma.ygztbh"
                  style="position: relative;left: 5px"
                  filterable
                  default-first-option
                  placeholder="请选择员工状态"
                >
                  <el-option
                    key="0"
                    label=""
                    value=""
                  />
                  <el-option
                    v-for="item in dictArray.ygztDictList"
                    :key="item.code"
                    :label="item.value"
                    :value="item.code"
                  />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="工作类型：">
                <el-select
                  v-model="queryParma.yggzlxbh"
                  style="position: relative;left: 5px"
                  filterable
                  default-first-option
                  placeholder="请选择工作类型"
                >
                  <el-option
                    key="0"
                    label=""
                    value=""
                  />
                  <el-option
                    v-for="item in dictArray.yggzlxDictList"
                    :key="item.code"
                    :label="item.value"
                    :value="item.code"
                  />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="工作状态：">
                <el-select
                  v-model="queryParma.yggzztbh"
                  style="position: relative;left: 5px"
                  filterable
                  default-first-option
                  placeholder="请选择工作状态"
                >
                  <el-option
                    key="0"
                    label=""
                    value=""
                  />
                  <el-option
                    v-for="item in dictArray.yggzztDictList"
                    :key="item.code"
                    :label="item.value"
                    :value="item.code"
                  />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="是否注销：">
                <el-select
                  v-model="queryParma.sfzxbs"
                  style="position: relative;left: 5px"
                  filterable
                  default-first-option
                  placeholder="请选择是否注销"
                >
                  <el-option
                    key="0"
                    label=""
                    value=""
                  />
                  <el-option
                    key="1"
                    label="是"
                    value="0"
                  />
                  <el-option
                    key="2"
                    label="否"
                    value="1"
                  />
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="24">
            <el-col :span="12">
              <el-form-item label="请假开始时间范围：" label-width="150px">
                <el-date-picker
                  v-model="timeArray.qjsjksArray"
                  clearable
                  type="daterange"
                  align="right"
                  value-format="yyyy-MM-dd HH:mm:ss"
                  unlink-panels
                  range-separator="至"
                  start-placeholder="开始日期"
                  end-placeholder="结束日期"
                  :picker-options="pickerOptions"
                  :default-time="['00:00:00', '23:59:59']"
                  @change="setChangeTimeHandle('qjsjks')"
                />
                <span>
                  <i style="margin-left: 5px;font-size: 18px;cursor: pointer" class="el-icon-circle-close" @click="setNoneByType('qjsjks')" />
                </span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="入职时间范围：" label-width="150px">
                <el-date-picker
                  v-model="timeArray.rzsjArray"
                  clearable
                  type="daterange"
                  align="right"
                  value-format="yyyy-MM-dd HH:mm:ss"
                  unlink-panels
                  range-separator="至"
                  start-placeholder="开始日期"
                  end-placeholder="结束日期"
                  :picker-options="pickerOptions"
                  :default-time="['00:00:00', '23:59:59']"
                  @change="setChangeTimeHandle('rzsj')"
                />
                <span>
                  <i style="margin-left: 5px;font-size: 18px;cursor: pointer" class="el-icon-circle-close" @click="setNoneByType('rzsj')" />
                </span>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="24">
            <el-col :span="12">
              <el-form-item label="请假结束时间范围：" label-width="150px">
                <el-date-picker
                  v-model="timeArray.qjsjjsArray"
                  clearable
                  type="daterange"
                  align="right"
                  value-format="yyyy-MM-dd HH:mm:ss"
                  unlink-panels
                  range-separator="至"
                  start-placeholder="开始日期"
                  end-placeholder="结束日期"
                  :picker-options="pickerOptions"
                  :default-time="['00:00:00', '23:59:59']"
                  @change="setChangeTimeHandle('qjsjjs')"
                />
                <span>
                  <i style="margin-left: 5px;font-size: 18px;cursor: pointer" class="el-icon-circle-close" @click="setNoneByType('qjsjjs')" />
                </span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="离职时间范围：" label-width="150px">
                <el-date-picker
                  v-model="timeArray.lzsjArray"
                  clearable
                  type="daterange"
                  align="right"
                  value-format="yyyy-MM-dd HH:mm:ss"
                  unlink-panels
                  range-separator="至"
                  start-placeholder="开始日期"
                  end-placeholder="结束日期"
                  :picker-options="pickerOptions"
                  :default-time="['00:00:00', '23:59:59']"
                  @change="setChangeTimeHandle('lzsj')"
                />
                <span>
                  <i style="margin-left: 5px;font-size: 18px;cursor: pointer" class="el-icon-circle-close" @click="setNoneByType('lzsj')" />
                </span>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="24" />
        </template>
      </el-form>
    </div>
    <!--    查询查询部分-->
    <div>
      <el-divider content-position="left"><span style="font-weight: bolder;font-size: 18px">员工信息展示</span></el-divider>
      <!--      数据操作按钮-->
      <div style="padding: 10px" align="right">
        <el-button-group>
          <el-button type="primary" icon="el-icon-plus" @click="handleAdd">新增</el-button>
          <el-button type="danger" icon="el-icon-delete" @click="handleDeleteBatch">批量删除</el-button>
        </el-button-group>
      </div>

      <el-table
        :data="dataSource"
        :border="true"
        align="center"
        empty-text="暂无数据"
        style="width: 100%"
        @selection-change="handleSelectionChange"
      >
        <el-table-column
          type="selection"
          width="55"
          align="center"
        />
        <el-table-column
          type="index"
          :index="indexMethod"
          label="#"
          width="50"
          align="center"
        />
        <el-table-column type="expand">
          <template slot-scope="props">
            <el-form label-position="left" inline class="demo-table-expand">
              <el-form-item label="性别：">
                <span>{{ props.row.employGender }}</span>
              </el-form-item>
              <el-form-item label="年龄：">
                <span>{{ props.row.employAge }}</span>
              </el-form-item>
              <el-form-item label="员工 ID">
                <span>{{ props.row.id }}</span>
              </el-form-item>
              <el-form-item label="工作天数：">
                <span>{{ props.row.employWorkTimes }}</span>
              </el-form-item>
              <el-form-item label="员工状态">
                <span>{{ props.row.employStatus }}</span>
              </el-form-item>
              <el-form-item label="工作形式">
                <span>{{ props.row.employWorkType }}</span>
              </el-form-item>
              <el-form-item label="工作状态">
                <span>{{ props.row.employWorkStatus }}</span>
              </el-form-item>
              <el-form-item label="入职时间：">
                <span>{{ props.row.employEntryTime }}</span>
              </el-form-item>
              <el-form-item label="离职时间：">
                <span>{{ props.row.employDepartureTime }}</span>
              </el-form-item>
              <el-form-item label="离职原因：">
                <span>{{ props.row.employDepartureResion }}</span>
              </el-form-item>
            </el-form>
          </template>
        </el-table-column>
        <el-table-column
          label="用户名"
          prop="userName"
        />
        <el-table-column
          label="员工类型名称"
          prop="employTypeName"
        />
        <el-table-column
          label="员工部门名称"
          prop="depName"
        />
        <el-table-column
          label="是否出勤"
          prop="attendFlag"
          align="center"
        >
          <template slot-scope="scope">
            {{ scope.row.attendFlag | checkAttendFlag(scope.row.attendFlag) }}
            <el-popover
              placement="right"
              width="625"
              trigger="click"
            >
              <el-descriptions size="small" style="width:600px" title="员工出勤信息详情" :column="3" colon border>
                <el-descriptions-item label="是否签到">
                  {{ rowAttendanceData.attendRecodeTime !== null ? '已签到' : '未签到' }}
                </el-descriptions-item>
                <el-descriptions-item v-if="rowAttendanceData.attendRecodeTime" label="签到时间">
                  {{ rowAttendanceData.attendRecodeTime }}</el-descriptions-item>
                <el-descriptions-item label="出勤开始时间">{{ rowAttendanceData.attendBeginTime | formatdate(rowAttendanceData.attendBeginTime) }}</el-descriptions-item>
                <el-descriptions-item label="出勤结束时间">{{ rowAttendanceData.attendEndTime | formatdate(rowAttendanceData.attendEndTime) }}</el-descriptions-item>
                <el-descriptions-item label="备注">{{ rowAttendanceData.memo }}</el-descriptions-item>
              </el-descriptions>
              <a v-if="scope.row.attendFlag !== '0'" slot="reference" style="margin-left: 5px;color: #409EFF" @click="showDetail(scope.row,'attendance')"><i class="el-icon-search" /></a>
            </el-popover>
          </template>
        </el-table-column>
        <el-table-column
          label="基本工资"
          header-align="center"
          align="right"
          min-width="80"
          prop="basicSalary"
        >
          <template slot-scope="{ row }">
            <span style="color:red;font-weight: bolder">{{ row.basicSalary !== null ? row.basicSalary + ' 元' : '尚未完善工资信息' }}</span>
          </template>
        </el-table-column>
        <el-table-column
          label="是否请假"
          prop="vacateFlag"
          align="center"
        >
          <template slot-scope="scope">
            {{ scope.row.vacateFlag | checkVacateFlag(scope.row.vacateFlag) }}
            <el-popover
              placement="right"
              width="625"
              trigger="click"
            >
              <el-descriptions size="small" style="width:600px" title="员工请假信息详情" :column="3" colon border>
                <el-descriptions-item label="开始时间" label-class-name="my-label" content-class-name="my-content">
                  {{ rowVacationData.vacateBeginTime | formatdate(rowVacationData.vacateBeginTime) }}</el-descriptions-item>
                <el-descriptions-item label="结束时间">{{ rowVacationData.vacateEndTime | formatdate(rowVacationData.vacateEndTime) }}</el-descriptions-item>
                <el-descriptions-item label="类型">{{ getDictsValue(rowVacationData.vacateType) }}</el-descriptions-item>
                <el-descriptions-item label="批准人">{{ rowVacationData.approverName }}</el-descriptions-item>
                <el-descriptions-item label="批准时间">{{ rowVacationData.approveTime }}</el-descriptions-item>
                <el-descriptions-item label="请假原因">{{ rowVacationData.vacateResion }}</el-descriptions-item>
              </el-descriptions>
              <a v-if="scope.row.vacateFlag !== '0'" slot="reference" style="margin-left: 5px;color: #409EFF" @click="showDetail(scope.row,'vacation')"><i class="el-icon-search" /></a>
            </el-popover>
          </template>
        </el-table-column>
        <el-table-column
          label="备注信息"
          min-width="100"
          prop="memo"
        />
        <el-table-column
          label="设置员工是否有效"
          align="center"
        >
          <template slot-scope="scope">
            <el-switch
              v-model="scope.row.valiFlag"
              active-value="1"
              inactive-value="0"
              active-color="#13ce66"
              inactive-color="#ff4949"
              @change="switchHandle(scope.row)"
            />
          </template>
        </el-table-column>
        <el-table-column
          label="操作"
          align="center"
        >
          <template slot-scope="scope">
            <el-button
              size="mini"
              @click="handleEdit(scope.$index, scope.row)"
            >编辑
            </el-button>
            <el-button
              size="mini"
              type="danger"
              @click="handleDelete(scope.$index, scope.row)"
            >删除
            </el-button>
          </template>
        </el-table-column>
      </el-table>
      <div align="center">
        <div style="display: inline-block;width: 60px;height:60px;line-height: 60px;text-align: center;font-size: 15px">
          <span style="text-align: center;line-height: 60px;width: 60px;height:60px;">共{{ dataTotals }}条</span>
        </div>
        <div style="display: inline-block">
          <el-pagination
            :current-page.sync="queryParma.pageIndex"
            :page-sizes="[5, 10, 15, 20]"
            :page-size="queryParma.pageSize"
            layout="total, sizes, prev,next, jumper"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
          />
        </div>
      </div>
    </div>
    <modal
      ref="modals"
      :employee-info="modifyData"
      :department-info="depInfoList"
      :employee-type-list="empTypeList"
      :employee-qjlx-list="dictArray.qjlxDictList"
      :employee-ygzt-list="dictArray.ygztDictList"
      :employee-yggzzt-list="dictArray.yggzztDictList"
      :employee-yggzlx-list="dictArray.yggzlxDictList"
      @reflushDataHandle="getEmpInfoListPageHandle"
    />
  </el-card>
</template>

<script>
import { getAllEmpType } from '@/api/ht/yytgl/yggl/yglxgl'
const { Message } = require('element-ui')
const { modifyOneEmpInfo } = require('@/api/ht/yytgl/yggl/ygxxgl')
const { getOneVacationInfo } = require('@/api/ht/yytgl/qjgl/qjxxcx')
const { getAllDepartmentInfo } = require('@/api/ht/yytgl/bmgl/bmxxgl')
const { getDictsByType, getDictsList } = require('@/api/dicts')
import modal from '@/views/ht/yytgl/yggl/ygxxcx/components/modal'
import { dropBatchEmpInfo, getAllEmpInfoPage } from '@/api/ht/yytgl/yggl/ygxxgl'
import { getOneAttendanceInfo } from '@/api/ht/yytgl/cqgl/cqxxcx'
const { fomatMilsToDate } = require('@/utils/DateUtil')
export default {
  name: 'Index',
  components: {
    modal
  },
  filters: {
    checkAttendFlag: function(flag) {
      if (flag === '0') {
        return '未出勤'
      }
      return '已出勤'
    },
    checkVacateFlag: function(flag) {
      if (flag === '11') {
        return '已请假，已批准'
      } else if (flag === '10') {
        return '已请假，未批准'
      }
      return '未请假'
    },
    formatdate: function(mils) {
      return fomatMilsToDate(mils)
    }
  },
  data() {
    return {
      dataSource: [], // 员工信息列表
      rowVacationData: {}, // 员工请假详情数据源
      rowAttendanceData: {}, // 员工出勤详情数据源
      dataTotals: 0, // 查询总条数
      modifyData: {}, // 待修改对象信息
      searchloding: false, // 搜索按钮加载
      toggleSearchStatus: false, // 查询是否展开
      dictArray: {
        qjlxDictList: [],
        ygztDictList: [],
        yggzlxDictList: [],
        yggzztDictList: []
      },
      timeArray: {
        qjsjksArray: [], // 请假开始时间范围数组
        qjsjjsArray: [], // 请假结束时间范围数组
        rzsjArray: [], // 入职时间范围数组
        lzsjArray: [] // 离职时间范围数组
      },
      queryParma: {
        pageIndex: 1,
        pageSize: 5,
        ygxx: '', // 员工信息
        yglxbh: '', // 员工类型编号
        qjlxbh: '', // 请假类型编号
        bmxxbh: '', // 部门信息编号
        gzMin: '', // 工资最小值
        gzMax: '', // 工资最大值
        qjsjksBegin: '', // 请假开始时间的开端
        qjsjksEnd: '', // 请假开始时间的末尾
        qjsjjsBegin: '', // 请假结束时间的开端
        qjsjjsEnd: '', // 请假结束时间的末尾
        sfcq: '', // 是否出勤 1 是 0 否
        sfqj: '', // 是否请假 1 是 0 否
        gzsj: '', // （工作时长 = 离职时间 - 入职时间）
        ygxb: '', // 员工性别 ( 1 - 男 0 - 女)
        rzsjBegin: '', // 入职时间-范围-开端
        rzsjEnd: '', // 入职时间-范围-结尾
        lzsjBegin: '', // 离职时间-范围-开端
        lzsjEnd: '', // 离职时间-范围-结尾
        ygztbh: '', // 员工状态编号 员工状态（00 - 在职、11 - 离职 、 01 - 请假 ）
        yggzlxbh: '', // 员工工作类型编号 工作形式（00 - 现场办公 、01 - 远程非本市办公、02 - 远程本市办公）
        yggzztbh: '', // 员工工作状态编号 当前工作状态（00 - 现场技术维护作业、01 - 办公室服务作业、02 - 上门维护作业、03 - 上门宣传指导作业、 04 - 作业完成，待作业、11 特殊情况，无作业）
        sfzxbs: '' // 是否员工注销标识 valiFlag;
      },
      empTypeList: [], // 员工类型信息集合
      depInfoList: [], // 部门信息集合
      hasselectedIdArray: [], // 已经选中的部门信息ID数组
      pickerOptions: {
        shortcuts: [{
          text: '最近一周',
          onClick(picker) {
            const end = new Date()
            const start = new Date()
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
            picker.$emit('pick', [start, end])
          }
        }, {
          text: '最近一个月',
          onClick(picker) {
            const end = new Date()
            const start = new Date()
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
            picker.$emit('pick', [start, end])
          }
        }, {
          text: '最近三个月',
          onClick(picker) {
            const end = new Date()
            const start = new Date()
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
            picker.$emit('pick', [start, end])
          }
        }]
      }
    }
  },
  mounted() {
    this.getEmpTypeListHandle() // 获取员工类型信息列表
    this.getEmpInfoListPageHandle() // 获取员工信息
    this.getALLDepInfo() // 获取部门信息列表
    this.getAllQueryDicts() // 获取所有查询条件字典
  },
  methods: {
    getEmpTypeListHandle() {
      this.getEmpTypeList()
    },
    getEmpInfoListPageHandle() {
      this.getEmpInfoListPage()
    },
    getAllQueryDicts() {
      this.getDicts('vacation_type')
      this.getDicts('employee_status')
      this.getDicts('employee_work_type')
      this.getDicts('employee_work_status')
    },
    getALLDepInfo() {
      this.getAllEmpInfos()
    },
    async getEmpTypeList() {
      const res = await getAllEmpType()
      const data = res.data.main
      const resp = res.data.respOutMsgHeader
      if (resp.respCode === 200) {
        this.empTypeList = data
      } else {
        Message({
          message: resp.msg || 'Error',
          type: 'error',
          duration: 2 * 1000
        })
      }
    },
    async getEmpInfoListPage() {
      const res = await getAllEmpInfoPage(this.queryParma)
      const data = res.data.main.dataArray
      const resp = res.data.respOutMsgHeader
      const totals = res.data.main.totalsData
      const currentPage = res.data.main.currentPage
      if (resp.respCode === 200) {
        setTimeout(() => {
          this.searchloding = false
        }, 500)
        this.dataSource = data
        this.dataTotals = totals
        this.queryParma.pageIndex = currentPage
      } else {
        Message({
          message: resp.msg || 'Error',
          type: 'error',
          duration: 2 * 1000
        })
      }
    },
    getDictsValue(code) {
      return getDictsList(this.dictArray.qjlxDictList, code)
    },
    async getDicts(type) {
      if (type === 'vacation_type') {
        const res = await getDictsByType(type)
        this.dictArray.qjlxDictList = res.data.main
      } else if (type === 'employee_status') {
        const res = await getDictsByType(type)
        this.dictArray.ygztDictList = res.data.main
      } else if (type === 'employee_work_type') {
        const res = await getDictsByType(type)
        this.dictArray.yggzlxDictList = res.data.main
      } else {
        const res = await getDictsByType(type)
        this.dictArray.yggzztDictList = res.data.main
      }
    },
    async getAllEmpInfos() {
      const res = await getAllDepartmentInfo()
      this.depInfoList = res.data.main
    },
    indexMethod(index) {
      return index + 1 + (this.queryParma.pageIndex - 1) * this.queryParma.pageSize
    },
    showDetail(row, type) {
      if (type === 'vacation') {
        this.getOneVacationInfo(row)
      } else {
        this.getOneAttendanceInfo(row)
      }
    },
    async getOneAttendanceInfo(row) {
      const res = await getOneAttendanceInfo(row.attendCode)
      const data = res.data.main
      const resp = res.data.respOutMsgHeader
      if (resp.respCode === 200) {
        this.rowAttendanceData = data
      } else {
        Message({
          message: '该员工尚未出勤，无法查看详情' || 'Error',
          type: 'error',
          duration: 2 * 1000
        })
      }
    },
    async getOneVacationInfo(row) {
      const res = await getOneVacationInfo(row.employVacateCode)
      const data = res.data.main
      const resp = res.data.respOutMsgHeader
      if (resp.respCode === 200) {
        this.rowVacationData = data
      } else {
        Message({
          message: '该员工尚未请假，无法查看详情' || 'Error',
          type: 'error',
          duration: 2 * 1000
        })
      }
    },
    switchHandle(row) {
      this.$confirm('如果设置无效操作，将会使得该员工关联的绝大部分功能失效或者无法正常使用系统, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.modifyEmpInfo(row)
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消'
        })
        row.valiFlag = '0'
      })
    },
    async modifyEmpInfo(row) {
      const res = await modifyOneEmpInfo(row)
      const resp = res.data.respOutMsgHeader
      if (resp.respCode === 200) {
        Message({
          message: '设置成功' || 'success',
          type: 'success',
          duration: 2 * 1000
        })
      } else {
        Message({
          message: resp.msg || 'Error',
          type: 'error',
          duration: 2 * 1000
        })
      }
    },
    setNoneByType(type) {
      this.timeArray = {}
      if (type === 'qjsjks') {
        this.queryParma.qjsjksBegin = ''
        this.queryParma.qjsjksEnd = ''
      } else if (type === 'qjsjjs') {
        this.queryParma.qjsjjsBegin = ''
        this.queryParma.qjsjjsEnd = ''
      } else if (type === 'rzsj') {
        this.queryParma.rzsjBegin = ''
        this.queryParma.rzsjEnd = ''
      } else if (type === 'lzsj') {
        this.queryParma.lzsjBegin = ''
        this.queryParma.lzsjEnd = ''
      } else {
        this.queryParma.qjsjksBegin = ''
        this.queryParma.qjsjksEnd = ''
        this.queryParma.qjsjjsBegin = ''
        this.queryParma.qjsjjsEnd = ''
        this.queryParma.rzsjksBegin = ''
        this.queryParma.rzsjksEnd = ''
        this.queryParma.lzsjBegin = ''
        this.queryParma.lzsjEnd = ''
        console.log(this.queryParma)
      }
    },
    setChangeTimeHandle(str) {
      if (str === 'qjsjks') {
        this.queryParma.qjsjksBegin = this.timeArray.qjsjksArray[0]
        this.queryParma.qjsjksEnd = this.timeArray.qjsjksArray[1]
      } else if (str === 'qjsjjs') {
        this.queryParma.qjsjjsBegin = this.timeArray.qjsjjsArray[0]
        this.queryParma.qjsjjsEnd = this.timeArray.qjsjjsArray[1]
      } else if (str === 'rzsj') {
        this.queryParma.rzsjBegin = this.timeArray.rzsjArray[0]
        this.queryParma.rzsjEnd = this.timeArray.rzsjArray[1]
      } else if (str === 'lzsj') {
        this.queryParma.lzsjBegin = this.timeArray.lzsjArray[0]
        this.queryParma.lzsjEnd = this.timeArray.lzsjArray[1]
      } else {
        console.log('参数出错！')
      }
    },
    handleAdd() {
      this.$refs.modals.checkModelType('add')
    },
    handleEdit(index, row) {
      // 使用父子传参方式
      this.modifyData = row
      this.$refs.modals.checkModelType('edit')
    },
    resetForm() {
      this.setNoneByType()
      this.queryParma = {
        pageIndex: 1,
        pageSize: 5,
        ygxx: '', // 员工信息
        yglxbh: '', // 员工类型编号
        qjlxbh: '', // 请假类型编号
        bmxxbh: '', // 部门信息编号
        gzMin: '', // 工资最小值
        gzMax: '', // 工资最大值
        qjsjksBegin: '', // 请假开始时间的开端
        qjsjksEnd: '', // 请假开始时间的末尾
        qjsjjsBegin: '', // 请假结束时间的开端
        qjsjjsEnd: '', // 请假结束时间的末尾
        sfcq: '', // 是否出勤 1 是 0 否
        sfqj: '', // 是否请假 1 是 0 否
        gzsj: '', // （工作时长 = 离职时间 - 入职时间）
        ygxb: '', // 员工性别 ( 1 - 男 0 - 女)
        rzsjBegin: '', // 入职时间-范围-开端
        rzsjEnd: '', // 入职时间-范围-结尾
        lzsjBegin: '', // 离职时间-范围-开端
        lzsjEnd: '', // 离职时间-范围-结尾
        ygztbh: '', // 员工状态编号 员工状态（00 - 在职、11 - 离职 、 01 - 请假 ）
        yggzlxbh: '', // 员工工作类型编号 工作形式（00 - 现场办公 、01 - 远程非本市办公、02 - 远程本市办公）
        yggzztbh: '', // 员工工作状态编号 当前工作状态（00 - 现场技术维护作业、01 - 办公室服务作业、02 - 上门维护作业、03 - 上门宣传指导作业、 04 - 作业完成，待作业、11 特殊情况，无作业）
        sfzxbs: '' // 是否员工注销标识 valiFlag;
      }
    },
    handleDelete(index, row) {
      const rowIdarray = []
      rowIdarray.push(row.employCode)
      this.dropOneEmpInfo(rowIdarray)
    },
    handleDeleteBatch() {
      this.dropBatchEmpInfo()
    },
    async dropOneEmpInfo(array) {
      const res = await dropBatchEmpInfo(array)
      const resp = res.data.respOutMsgHeader
      if (resp.respCode === 200) {
        Message({
          message: resp.msg || 'Error',
          type: 'error',
          duration: 2 * 1000
        })
        this.getEmpInfoListPageHandle()
      } else {
        Message({
          message: resp.msg || 'Error',
          type: 'error',
          duration: 2 * 1000
        })
      }
    },
    async dropBatchEmpInfo() {
      const res = await dropBatchEmpInfo(this.hasselectedIdArray)
      const resp = res.data.respOutMsgHeader
      if (resp.respCode === 200) {
        Message({
          message: resp.msg || 'Error',
          type: 'error',
          duration: 2 * 1000
        })
        this.getEmpInfoListPageHandle()
      } else {
        Message({
          message: resp.msg || 'Error',
          type: 'error',
          duration: 2 * 1000
        })
      }
    },
    handleSizeChange(val) {
      this.queryParma.pageSize = val
      this.getEmpInfoListPageHandle()
    },
    handleCurrentChange(val) {
      this.queryParma.pageIndex = val
      this.getEmpInfoListPageHandle()
    },
    handleSelectionChange(selections) {
      const rowIdArray = []
      for (const selection of selections) {
        rowIdArray.push(selection.employCode)
      }
      this.hasselectedIdArray = rowIdArray
    }
  }
}
</script>

<style scoped>
</style>
